package com.gcsoftware.web.mapper.providers;

import com.gcsoftware.web.beans.T_CON_DSITEM_IPARAMS;
import org.apache.ibatis.annotations.Param;

import java.text.MessageFormat;
import java.util.List;

/**
 * Created by qs on 2018/4/3.
 */
public class DsiInterfsParamsProvider {
    public String batchInsert(@Param(value = "list") List<T_CON_DSITEM_IPARAMS> list) {
        StringBuilder sb = new StringBuilder();
        sb.append("INSERT INTO T_CON_DSITEM_IPARAMS ");
        sb.append("(c_DS_ITEM_ID,c_INTERF_ID,c_IPARAMS_ID,c_IPARAMS_SENS) ");
        sb.append("VALUES ");
        MessageFormat mf = new MessageFormat("(#'{'list[{0}].c_DS_ITEM_ID},#'{'list[{0}].c_INTERF_ID},#'{'list[{0}].c_IPARAMS_ID},#'{'list[{0}].c_IPARAMS_SENS})");
        for (int i = 0; i < list.size(); i++) {
            //if (list.get(i).getIfChecked() == 1) {
                sb.append(mf.format(new Object[]{i}));
                if (i < list.size() - 1) {
                    sb.append(",");
                }
            //}
        }
        return sb.toString();
    }

}
